<!DOCTYPE HTML>
<html>
<head>

    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <title>详情</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/css/uploadifive.css">
    <link type="text/css" rel="stylesheet" href="/js/plugins/layer/laydate/skins/default/laydate.css" id="LayDateSkin">


</head>
<body>
<h2>{{if .update}}更新{{else}}添加{{end}}</h2>
<!--style给定宽度可以影响编辑器的最终宽度-->

<!--style给定宽度可以影响编辑器的最终宽度-->
<form id="FORM_validate" action="/advertisement/{{if .update}}update{{else}}add{{end}}" method="post">
    <input id="form_Id" type="hidden" value="{{if .update}}{{.Advertisement.Id}}{{end}}" name="{{if .update}}Id{{end}}">
    <div class="">
    	<div class="form-group col-md-12">
            <label class="col-md-3 control-label">广告类型：</label>
            <div class="col-md-9">
                <select class="form-control m-b" name="ManageType">
                    <option {{if .update}}{{if eq 0 .Advertisement.ManageType}}selected="selected"{{end}}{{else}}{{if eq 0 .Type}}selected="selected"{{end}}{{end}} value="0">扫码页面banner</option>
                    <option {{if .update}}{{if eq 1 .Advertisement.ManageType}}selected="selected"{{end}}{{else}}{{if eq 1 .Type}}selected="selected"{{end}}{{end}} value="1">抽奖页面banner</option>
                </select>
            </div>
        </div>
		<div class="form-group col-md-12">
            <div class="col-md-3">
            	<label class="control-label">图片路径：</label>
                <input id="form_PicPath" type="hidden" name="PicPath" value="{{if .update}}{{.Advertisement.PicPath}}{{end}}" required="" aria-required="true">
                <button id="file_upload_PicPath" name="file_upload_PicPath" type="file" multiple="true"></button>
            </div>
            <div class="col-md-9">
                <img id="form_pic_PicPath" src="{{if .update}}{{.Advertisement.PicPath}}{{else}}/img/image.png{{end}}"
                     style="max-height: 380px;width: auto;">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">图片链接（站内）：</label>
            <div class="col-md-9">
                <input id="form_PicHref" name="PicHref" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Advertisement.PicHref}}{{end}}">
            </div>
        </div>
		<div class="form-group col-md-12">
            <label class="col-md-3 control-label">介绍：</label>
            <div class="col-md-9">
                <input id="form_Introduction" name="Introduction" class="form-control" placeholder="请在此输入" value="{{if .update}}{{.Advertisement.Introduction}}{{end}}">
            </div>
        </div>
		
    	<div class="form-group col-md-12">
            <div class="col-md-12 col-md-offset-3">
                <button class="btn btn-primary" type="submit">保存内容</button>
                {{if .update}}{{else}}
                <button class="btn btn-white" type="submit">取消</button>
                {{end}}
            </div>
        </div>
    </div>
</form>



<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/js/jquery.uploadifive.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8" src="/js/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/js/ueditor.all.min.js"></script>
<script type="text/javascript" src="/lang/zh-cn/zh-cn.js"></script>
<script src="/js/plugins/validate/jquery.validate.min.js"></script>
<script src="/js/plugins/validate/messages_zh.min.js"></script>


<!-- jQuery UI -->
<script src="/js/jquery-ui-1.10.4.min.js"></script>
<!-- laydate js -->
<script src="/js/plugins/layer/laydate/laydate.js"></script>

<!--form validate-->
<script>
    $().ready(function () {
        // validate the comment form when it is submitted
        $("#FORM_validate").validate({
            rules: {
                PicHref:{
                    required:true,
                    minlength: 2
                },
                Introduction:{
                    required:true,
                    minlength: 2
                },
            }
        });
    });
</script>


<!--pic upload-->
<script type="text/javascript">
    $(function () {
        $('#file_upload_PicPath').uploadifive({
            'formData': {
                'Id': $("#form_Id").attr("value"),
                'imagepath': $("#form_PicPath").attr("value")
            },
            'uploadScript': '/advertisement/picUp',
            'fileTypeExts': '*.jpg; *.jpeg; *.png',
            'removeCompleted' : true,
            'fileSizeLimit':"10MB",
            'buttonClass':"btn-info",
            'multi': false,
            'onUploadComplete' : function(file, data) {
                var url_new = $.parseJSON(data).Data;
                $("#form_pic_PicPath").attr("src", url_new);
                $("#form_PicPath").attr("value", url_new.substring(0, url_new.indexOf("?time")));
            },
            'onUploadError': function (file, errorCode, errorMsg, errorString) {
                alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
            }
        });
    });
</script>




</body>
</html>